package com.bwie.controller;

import com.bwie.mapper.TbBrandMapper;
import com.bwie.pojo.TbBrand;
import com.bwie.service.TbBrandService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: zhaijiaqi
 * @Date: 2025/6/20 15:30
 * @Description:
 **/
@RestController
@RequestMapping("/shop/index")
public class IndexController {

    @Autowired
    TbBrandService tbBrandService;

    /**
     * 分页获取品牌列表
     * @param pageInfoVo
     * @return
     */
    @PostMapping("/getBrandList")
    public R getBrandList(@RequestBody PageInfoVo pageInfoVo){
        return tbBrandService.getBrandList(pageInfoVo);
    }

    /**
     * 添加品牌
     * @param tbBrand
     * @return
     */
    @PostMapping("/AddBrand")
    public R AddBrand(@RequestBody @Validated TbBrand tbBrand){
        return tbBrandService.AddBrand(tbBrand);
    }

    /**
     * 修改状态
     * @param tbBrand
     * @return
     */
    @PostMapping("/updataStatus")
    public R updataStatus(@RequestBody TbBrand tbBrand){
        return tbBrandService.updataStatus(tbBrand);
    }

    /**
     * 删除品牌
     * @param brandId
     * @return
     */
    @PostMapping("/deleteBrand/{brandId}")
    public R deleteBrand(@PathVariable("brandId") Integer brandId){
        return tbBrandService.deleteBrand(brandId);
    }

    /**
     * 批量删除
     * @param brandIds
     * @return
     */
    @PostMapping("/DeleteBacth")
    public R DeleteBacth(@RequestBody List<TbBrand> tbBrands){
        return tbBrandService.DeleteBacth(tbBrands);
    }

    /**
     * 品牌列表
     * @return
     */
    @PostMapping("/BrandList")
    public R BrandList(){
        return tbBrandService.BrandList();
    }
}
